# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name:        InService.py
# Purpose:
#
# Author:      Drago@
#
# Created:     06.08.2009
# Copyright:   (c) Drago@ 2009
# Licence:     <your licence>
#-------------------------------------------------------------------------------
#!/usr/bin/env python

import Pyro.core

from pygs.interfaces import IInServiceInterface, IPersistenceInterface, BaseService
from pygs.data import Point

from pygs.decorators import hasRight

class InService(BaseService, Pyro.core.ObjBase, IInServiceInterface):
    """
        "In" service implementation
    """

    def __init__(self):
        Pyro.core.ObjBase.__init__(self)

    def startup(self, params = None):
        BaseService.startup(self, params)
        pass

    def shutdown(self):
        BaseService.shutdown(self)
        pass

    @hasRight('AddPoints')
    def savePoints(self, token, points):
        # input parameters check
        notPointInstanceList = filter(lambda x: not isinstance(x, Point), points)
        assert not notPointInstanceList, '"points" parameter must contains only instances of Point type!'
        # save point
        self.getServiceProvider().implementation(IPersistenceInterface).addPoints(points)


